import { Component } from 'react'
import { View, Text, Button, Image } from '@tarojs/components'
import './activity.less'
export default class Activity extends Component {
    constructor(){
        super(...arguments)
        this.state={
            "activity":[
              {
                type:"cut",
                content:[
                  {total:48,cut:10},
                  {total:58,cut:20},
                  {total:100,cut:30}
                ],
              }
            ]
        }
    }
    getTextByType(type){
      let result = "减";
      switch (type) {
        case "cut":
          break;
        default:
          break;
      }
      return result;
    }
    getContent(arr){
      return arr.map((item,index)=>`满${item.total}减${item.cut}`).join(";")
    }
  render () {
    let {activity:[firstItem]}=this.state;
    return (
      <View className='activity'>
        <Text className='text'>{this.getTextByType(firstItem.type)}</Text>
        <Text className='content'>{this.getContent(firstItem.content)}</Text>
        <Text className='num'>{this.state.activity.length}个活动</Text>
      </View>
    )
  }
}
